
package xj.graph2d.app.diagram;

import xj.graph2d.Document;
import xj.graph2d.GraphDocument;
import xj.graph2d.app.DrawApp;
import xj.graph2d.layout.ClassDiagramLayout;

public class DiagramUtil { 

  /*
   * Type: 
   *       Document.DocumentType.UML_Class_Diagram 
   *       Document.DocumentType.UML_State_Diagram
   *       ....
   */
  public static GraphDocument addNewDiagram(DrawApp main, Document.DocumentType type, String name) { 
    if (main != null && type != null && name != null) {
      main.newProjectItem(null, name, type);
      GraphDocument diagram = (GraphDocument) main.getDoc();
      if (type == Document.DocumentType.UML_Class_Diagram) { 
	diagram.setGraphLayoutManager(new ClassDiagramLayout(diagram));    
      }
      return diagram;
    }
    return null;
  }


}
